package com.whfc.fse.xxl.job;

import com.whfc.XxlJobConfig;
import com.whfc.common.enums.NetState;
import com.whfc.fse.dao.*;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.stereotype.Component;

/**
 * @author qzexing
 * @version 1.0
 * @date 2021-01-05 14:32
 */
@Component
@ConditionalOnBean(XxlJobConfig.class)
public class FseDeviceStatusJob {

    @Autowired
    private FseBridgeMapper fseBridgeMapper;

    @Autowired
    private FseGantryMapper fseGantryMapper;

    @Autowired
    private FseLiftMapper fseLiftMapper;

    @Autowired
    private FseCraneMapper fseCraneMapper;

    @Autowired
    private FseCrawlerMapper fseCrawlerMapper;

    /**
     * 更新特种设备状态信息 每天凌晨1点更新
     */
    @XxlJob("syncDeviceState")
    public void syncDeviceState() {
        Integer netState = NetState.OFFLINE.getValue();
        fseCraneMapper.updateAllDeviceNetState(netState);
        fseLiftMapper.updateAllDeviceNetState(netState);
        fseGantryMapper.updateAllDeviceNetState(netState);
        fseBridgeMapper.updateAllDeviceNetState(netState);
        fseCrawlerMapper.updateAllDeviceNetState(netState);
    }

}
